#include <cstdio>
#include <vector>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 1e6 + 10;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int base = 998544323;
ull a[maxn];
char s[maxn];
vector<ull> v;

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    scanf("%s", s);
    ull p = 1e9 + 9, r = 1, h = 0;
    int len = strlen(s);
    for (int i = 0; i < n && i < len; i++) // 计算出前n位
        h = h * p + s[i], r *= p;
    if (len >= n) // 该串长度大于n， 加进去
        v.push_back(h);
    for (int i = n; i < len; i++)
        h = h * p + s[i] - s[i - n] * r, v.push_back(h); // 计算其他串的hash值
    sort(v.begin(), v.end());
    int tot = unique(v.begin(), v.end()) - v.begin();
    printf("%d\n", tot);
    return 0;
}